Oozie Email Action Extension

Email为同步执行,将执行完后再执行其他活动, to addresses cc addresses (optional) subject body

语法:

<workflow-app name="[WF-DEF-NAME]" xmlns="uri:oozie:workflow:0.1">
    ...
    <action name="[NODE-NAME]">
        <email xmlns="uri:oozie:email-action:0.2">
            <to>[COMMA-SEPARATED-TO-ADDRESSES]</to>
            <cc>[COMMA-SEPARATED-CC-ADDRESSES]</cc> <!-- cc is optional -->
            <subject>[SUBJECT]</subject>
            <body>[BODY]</body>
            <content_type>[CONTENT-TYPE]</content_type> <!-- content_type is optional -->
        </email>
        <ok to="[NODE-NAME]"/>
        <error to="[NODE-NAME]"/>
    </action>
    ...
</workflow-app>

配置:

oozie-site.xml

oozie.email.smtp.host - SMTP 服务器主机名(localhost by default).

oozie.email.smtp.port - SMTP server 连接端口(25 by default).

oozie.email.from.address - 邮件给所有的地址The from address to be used for mailing all emails (oozie@localhost by default).

oozie.email.smtp.auth - 是否启用验证. (false by default).

oozie.email.smtp.username - the username to login as (empty by default).

oozie.email.smtp.password - the username's password (empty by default).

示例:

<workflow-app name="sample-wf" xmlns="uri:oozie:workflow:0.1">
    ...
    <action name="an-email">
        <email xmlns="uri:oozie:email-action:0.1">
            <to>bob@initech.com,the.other.bob@initech.com</to>
            <cc>will@initech.com</cc>
            <subject>Email notifications for ${wf:id()}</subject>
            <body>The wf ${wf:id()} successfully completed.</body>
        </email>
        <ok to="myotherjob"/>
        <error to="errorcleanup"/>
    </action>
    ...
</workflow-app>

Email XML-Schema

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:email="uri:oozie:email-action:0.2" elementFormDefault="qualified"
           targetNamespace="uri:oozie:email-action:0.2">
.
    <xs:element name="email" type="email:ACTION"/>
.
    <xs:complexType name="ACTION">
        <xs:sequence>
            <xs:element name="to" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="cc" type="xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name="subject" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="body" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="content_type" type="xs:string" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>